package com.itheima;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @auther Macrydy
 * @date 2020/7/11 14:30
 */
public class ThreadPool03 {
    public static void main(String[] args) {
       /* public ThreadPoolExecutor(
            int corePoolSize,  //核心线程的最大值，不能小于0
            int maximumPoolSize, //最大线程数，不能小于等于0，maximumPoolSize >= corePoolSize
            long keepAliveTime,//空闲线程最大存活时间,不能小于0
            TimeUnit unit,//时间单位
            BlockingQueue<Runnable> workQueue,//任务队列，不能为null
            ThreadFactory threadFactory,//创建线程工厂,不能为null
            RejectedExecutionHandler handler//任务的拒绝策略,不能为null
          )*/
        ThreadPoolExecutor pool = new ThreadPoolExecutor(
                2,
                5,
                2,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(10),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy()
        );

        pool.submit(()->{
            System.out.println(Thread.currentThread().getName() + "在执行了");
        });

        pool.submit(()->{
            System.out.println(Thread.currentThread().getName() + "在执行了");
        });

        pool.shutdown();
    }
}
